<script src="/javascripts/util.js" type="text/javascript"></script>
<script src="/javascripts/calendar.js" type="text/javascript"></script>
<script src="/javascripts/prototype.js" type="text/javascript"></script>
<script type="text/javascript">
        function checkNum(flag, msg_id, obj_name, msg_text){
                if (flag) {
                        if ($(obj_name).value == "" || ! digCheck($(obj_name).value))
                        {
                                $(msg_id).innerText = msg_text;
                                $(msg_id).style.display = "block";
                                return false;
                        }
                        else return true;
                }
                else {
                        $(msg_id).style.display = "none";
                }
        }

        function checkDate()
        {
                //if (checkNum(true,'id_account_id','employee_account_id','员工ID输入错误'))
                        frmSalePaper.submit();
        }
function showPaperWindow(id)
{
    window.open("/sale/show_print_sale_paper/"+id,"_blank","height=700,width=700,top=300,left=400,toolbar=no,menubar=no,scrollbars=yes,resizable=no,location=no,status=no");
}
function showAgentWindow(id)
{
    window.open("/other_org/agent_info/"+id,"_blank","height=500,width=500,top=300,left=400,toolbar=no,menubar=no,scrollbars=yes,resizable=no,location=no,status=no");
}
</script>
<h1>报表中心 - <span id="secondHeading">员工业绩</span></h1>
<% if @flash[:notice] -%>
<div id="notice"><%= @flash[:notice] %></div>
<% end -%>
<form id="input-form" name="frmSalePaper" action="/query/employee_sale" method="post">
<table id="INPUT_TABLE">
	<tr>
               <!-- <td width="15%"> 员工ID：&nbsp;&nbsp;&nbsp;&nbsp; </td>
                <td>
                <input type="text" id="employee_account_id" name="account_id" size="20" maxlength="20" onfocus ="checkNum(false,'id_account_id')" onblur="checkNum(true,'id_account_id',this.id,'员工ID输入错误')"/> <div class="redNsg" id="id_account_id" style="display:none;"></div>
                </td>-->
 <TD width="20%">员工：</TD>
	    <TD><select name="employee_id">
	    <%@employees.each do |employees|%>
	    <option value="<%=employees.id%>"><%=employees.name%></option>
	    <%end%>
            </select>
            </TD>
	</tr>
	<tr>
                <td> 起始时间：</td>
                <td>
                        <!-- <input id="beginDate" type="text" name="from"> -->
                        <script language=javascript>
                        var beignDate=new dateSelector();
                        beignDate.inputID='beginDate';
                        beignDate.inputName='from';
                        beignDate.display();
                        </script>       
                </td>
	</tr>
	<tr>
                <td>结束时间：</td>
                <td>
                        <!--<input id="endDate" type="text" name="to">-->
                        <script language=javascript>
                        var endDate=new dateSelector();
                        endDate.inputID='endDate';
                        endDate.inputName='to';
                        endDate.display();
                        </script>
                </td>
	</tr>
	<tr>
                <td colspan="2" align="right">　
                        <input  type="button" value="查询" class="sub" onclick="checkDate()">
                </td>
        </tr>
</table>
</form>
<%if @sale_papers%>
<TABLE border="0" id="LIST_TB">
	<TR id="LIST_TB_TITLE">
      <td nowrap>订单号</td>
      <td nowrap>销售</td>
      <td nowrap>购买方</td>
      <td>状态</td>
      <td>销售日期</td>
      <td>支付</td>
    </tr>
    <%@sale_papers.each do |paper|%>
    <TR id="LIST_TB_CONTENT1">
      <td><a href="javascript:showPaperWindow(<%=paper.id%>)"><%=paper.id%></a></td>
      <td><%=paper.employee.name%></td>
      <td><a href="javascript:showAgentWindow(<%=paper.agent.id%>)"><%=paper.agent.name%></a></td>
      <td><%='<font color="green">已通过</font>' if paper.papertype.eql? 'OK'%> <%='未审批' if paper.papertype.eql? 'UN'%> <%= '<font color="red">未通过</font>' if paper.papertype.eql? 'NO'%> <%='已停用' if paper.papertype.eql? 'CA'%><%='已补齐' if paper.papertype.eql? 'GO'%><%='已完成' if paper.papertype.eql? 'NDFD'%><%='已退货' if paper.papertype.eql? 'RE'%>
      <td><%=paper.sale_date_at%></td>
      <td><%='<font color="red">未支付</font>' if paper.charge.eql? 'no'%><%='<font color="green">已支付</font>' if paper.charge.eql? 'yes'%></td>
    </tr>
    <%end%>
    <tr id="LIST_TB_CONTENT1">
        <td colspan="7">销售额:<%if @total!=nil%><%=sprintf("%#.2f",@total[0].total)%><%end%>元</td>
    </tr>
</table>
<table>
        <tr>
                <td>
                        <input type="button" value="打印当前页" class="sub" onclick="openPrintWindow('LIST_TB')"/>
                        <input type="button" value="导出当前数据" class="sub" onclick="CellAreaExcel('LIST_TB')"/>
                </td>
        </tr>
</table>
<%end%>
